package vn.com.tiz.DocumentZ.utils;
/**
 * This class will monitor log in application.
 * 
 */
import android.content.Context;
import android.os.Debug;
import android.util.Log;

public class LogTools {

	public static boolean TURN_ON = true;
	public static String TAG_DEFAULT ="TrungTT";
	
	public static void debug(String log){
		
		if(TURN_ON)	Log.d(TAG_DEFAULT,log);
	}
	
	public static void debug(Class<?> cls, String log){
		
		String tag = cls.getClass().getSimpleName();
		if(TURN_ON)	Log.d(tag,log);
	}
	
	public static void debug(Context context, String log){
		
		String tag = context.getClass().getSimpleName();
		if(TURN_ON)	Log.d(tag,log);
	}
	
	public static void info(String log){
		
		if(TURN_ON)	Log.i(TAG_DEFAULT,log);
	}
	
	public static void memoryUsedinfo(Context context){
		
		if(TURN_ON)	{
			String tag = context.getClass().getSimpleName();
			int memUsedMB = (int) (Debug.getNativeHeapAllocatedSize() / 1048576L);
			int memUsedKB = (int) (Debug.getNativeHeapAllocatedSize() / 1024L);			
			Log.e(tag," Memory used :  " + memUsedMB  + "("+ memUsedKB + " KB)");
		}
	}

	public static void memoryUsedinfo(){
		
		if(TURN_ON)	{			
			int memUsedMB = (int) (Debug.getNativeHeapAllocatedSize() / 1048576L);
			int memUsedKB = (int) (Debug.getNativeHeapAllocatedSize() / 1024L);			
			Log.e(TAG_DEFAULT," Memory used :  " + memUsedMB  + "MB ("+ memUsedKB + " KB)");
		}
	}
}
